package com.zbc.mapper;

import com.github.pagehelper.Page;
import com.zbc.annotation.AutoFill;
import com.zbc.dto.DishPageDTO;
import com.zbc.entity.Dish;
import com.zbc.entity.Flavors;
import com.zbc.enumeration.OperationType;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface DishMapper {
    Page<Dish> page(DishPageDTO dishPageDTO);

    @AutoFill(OperationType.INSERT)
    void addDish(Dish dish);

    void insertDishFlavors(List<Flavors> flavors);

    @AutoFill(OperationType.UPDATE)
    void updateDish(Dish dish);

    void deleteDish(Integer[] ids);

    @Select("select * from dish where id = #{id}")
    Dish getDishById(Integer id);

    @Select("select * from dish_flavor where dish_id = #{id}")
    List<Flavors> getFlavorByDishId(Integer id);

    void deleteDishFlavors(Integer[] ids);
}
